package com.huadao.cart_ccs.common.deviceController;

import com.huadao.cart_ccs.common.ParamsPreferences;

import java.util.Date;

public class TemperatureController extends BaseEnvironmentController {

    //误差
    private final double tolerance=1;

    //校准
    private static double adjust;
//    private double adjustTemperature;//校准后的温度，根据adjust值校准后的值

    private static final TemperatureController ourInstance = new TemperatureController();

    public static TemperatureController getInstance() {
        return ourInstance;
    }

    private TemperatureController() {
        adjust=ParamsPreferences.getInstance().getTemperatureAdjust();
    }

    @Override
    public double getTolerance() {
        return tolerance;
    }

    public void adjust(double adjust) {
        this.adjust = adjust;
    }

    public double calculatedTemperature(double temperature) {
        return temperature-adjust;
    }

//    public Double getAdjustSettedValue() {
//        if(settedValue==null){
//            return null;
//        }else {
//            return settedValue+adjust;
//        }
//    }

    @Override
    public Double getSettedValue() {
        if(settedValue==null){
            return null;
        }else {
            return settedValue-adjust;
        }
//        return super.getSettedValue();
    }
}
